<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Promise异步回调</title>
</head>
<body>
<script type="text/javascript">
var p1 = new Promise(function(resolve) {
    setTimeout(function() {
      resolve(1);
      console.log(1)
    } , 300);
});

var p2 = new Promise(function(resolve) {
    setTimeout(function() {
      resolve(2);
      console.log(2)
    } , 500);
});

p1.then(function(val){
	console.log('then: ' + val)
})

console.log(3)

 Promise.all([p1,p2]).then(res =>{
 	console.log(res);
 });

</script>

<div>
  输出顺序
  3
  1
  then: 1
  (2) [1, 2]
</div>
</body>
</html>




